package com.codegenerate.demo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.LocalDateTime;


@TableName(value ="sys_class")
public class SysClass implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private long id;









    /**
     * 分类名称
     */
    @TableField(value = "name")
    private String name;




    /**
     * 所属上级类别[关系=SysClass]
     */
    @TableField(value = "parent_id")
    private int parentId;




    /**
     * 所有分类路径
     */
    @TableField(value = "parent_id_path")
    private String parentIdPath;




    /**
     * 拓展类型
     */
    @TableField(value = "expend_type")
    private String expendType;




    /**
     * 类别深度
     */
    @TableField(value = "deep")
    private int deep;




    /**
     * 分类类型名称
     */
    @TableField(value = "type_info")
    private String typeInfo;




    /**
     * 分类图片[查询]
     */
    @TableField(value = "img")
    private String img;




    /**
     * 排序号
     */
    @TableField(value = "order_num")
    private int orderNum;




    /**
     * 备注
     */
    @TableField(value = "remarks")
    private String remarks;




    /**
     * 信息级别 0系统级 10租户级
     */
    @TableField(value = "info_level")
    private int infoLevel;




    /**
     * 租户类型 1应用管理者2应用消息者
     */
    @TableField(value = "tenant_type")
    private int tenantType;




    /**
     * 租户ID
     */
    @TableField(value = "tenant_id")
    private int tenantId;




    /**
     * 有效状态[数据字典=del_state] 1有效  5删除
     */
    @TableField(value = "del_state")
    private int delState;




    /**
     * 添加人
     */
    @TableField(value = "add_user")
    private String addUser;




    /**
     * 添加人ID
     */
    @TableField(value = "add_user_id")
    private int addUserId;




    /**
     * 添加时间
     */
    @TableField(value = "add_time")
    private LocalDateTime addTime;




    /**
     * 最近更新人
     */
    @TableField(value = "edit_user")
    private String editUser;




    /**
     * 最近更新人ID
     */
    @TableField(value = "edit_user_id")
    private int editUserId;




    /**
     * 最近更新时间
     */
    @TableField(value = "last_edit_time")
    private LocalDateTime lastEditTime;




    /**
     * 服务器编号ID
     */
    @TableField(value = "server_number")
    private int serverNumber;


    /**
     *  是否有子节点
     */
    @TableField(exist = false)
    private boolean haveNext;

    public boolean isHaveNext() {
        return haveNext;
    }

    public void setHaveNext(boolean haveNext) {
        this.haveNext = haveNext;
    }

    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public int getParentId() {
        return parentId;
    }
    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    public String getParentIdPath() {
        return parentIdPath;
    }
    public void setParentIdPath(String parentIdPath) {
        this.parentIdPath = parentIdPath;
    }

    public String getExpendType() {
        return expendType;
    }
    public void setExpendType(String expendType) {
        this.expendType = expendType;
    }

    public int getDeep() {
        return deep;
    }
    public void setDeep(int deep) {
        this.deep = deep;
    }

    public String getTypeInfo() {
        return typeInfo;
    }
    public void setTypeInfo(String typeInfo) {
        this.typeInfo = typeInfo;
    }

    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }

    public int getOrderNum() {
        return orderNum;
    }
    public void setOrderNum(int orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public int getInfoLevel() {
        return infoLevel;
    }
    public void setInfoLevel(int infoLevel) {
        this.infoLevel = infoLevel;
    }

    public int getTenantType() {
        return tenantType;
    }
    public void setTenantType(int tenantType) {
        this.tenantType = tenantType;
    }

    public int getTenantId() {
        return tenantId;
    }
    public void setTenantId(int tenantId) {
        this.tenantId = tenantId;
    }

    public int getDelState() {
        return delState;
    }
    public void setDelState(int delState) {
        this.delState = delState;
    }

    public String getAddUser() {
        return addUser;
    }
    public void setAddUser(String addUser) {
        this.addUser = addUser;
    }

    public int getAddUserId() {
        return addUserId;
    }
    public void setAddUserId(int addUserId) {
        this.addUserId = addUserId;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }
    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public String getEditUser() {
        return editUser;
    }
    public void setEditUser(String editUser) {
        this.editUser = editUser;
    }

    public int getEditUserId() {
        return editUserId;
    }
    public void setEditUserId(int editUserId) {
        this.editUserId = editUserId;
    }

    public LocalDateTime getLastEditTime() {
        return lastEditTime;
    }
    public void setLastEditTime(LocalDateTime lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public int getServerNumber() {
        return serverNumber;
    }
    public void setServerNumber(int serverNumber) {
        this.serverNumber = serverNumber;
    }




    /**
     * build
     */
    public static SysClass build(){
        SysClass tempEntity = new SysClass();
        return tempEntity;
    }

    /**
     * build
     */
    public  static void setDefaultValue(SysClass temp){

        if(temp.getId()<=0){
            temp.setId(0);
        }

        if(StringUtils.isEmpty(temp.getName())){
            temp.setName("");
        }

        if(temp.getParentId()<=0){
            temp.setParentId(0);
        }

        if(StringUtils.isEmpty(temp.getParentIdPath())){
            temp.setParentIdPath("");
        }

        if(StringUtils.isEmpty(temp.getExpendType())){
            temp.setExpendType("");
        }

        if(temp.getDeep()<=0){
            temp.setDeep(0);
        }

        if(StringUtils.isEmpty(temp.getTypeInfo())){
            temp.setTypeInfo("");
        }

        if(StringUtils.isEmpty(temp.getImg())){
            temp.setImg("");
        }

        if(temp.getOrderNum()<=0){
            temp.setOrderNum(0);
        }

        if(StringUtils.isEmpty(temp.getRemarks())){
            temp.setRemarks("");
        }

        if(temp.getInfoLevel()<=0){
            temp.setInfoLevel(0);
        }

        if(temp.getTenantType()<=0){
            temp.setTenantType(0);
        }

        if(temp.getTenantId()<=0){
            temp.setTenantId(0);
        }

        if(temp.getDelState()<=0){
            temp.setDelState(1);
        }

        if(StringUtils.isEmpty(temp.getAddUser())){
            temp.setAddUser("");
        }

        if(temp.getAddUserId()<=0){
            temp.setAddUserId(0);
        }

        if(null==temp.getAddTime()){
            temp.setAddTime(LocalDateTime.now());
        }

        if(StringUtils.isEmpty(temp.getEditUser())){
            temp.setEditUser("");
        }

        if(temp.getEditUserId()<=0){
            temp.setEditUserId(0);
        }

        if(null==temp.getLastEditTime()){
            temp.setLastEditTime(LocalDateTime.now());
        }

        if(temp.getServerNumber()<=0){
            temp.setServerNumber(0);
        }



    }

    @JsonIgnore
    public LambdaQueryWrapper<SysClass> getQueryAll() {
        var  query = new QueryWrapper<SysClass>().lambda();

        if(this.id>0){
            query.eq(SysClass::getId, this.id);
        }

        if(!StringUtils.isEmpty(this.name)){
            query.eq(SysClass::getName, this.name);
        }

        if(this.parentId>=0){
            query.eq(SysClass::getParentId, this.parentId);
        }

        if(!StringUtils.isEmpty(this.parentIdPath)){
            query.eq(SysClass::getParentIdPath, this.parentIdPath);
        }

        if(!StringUtils.isEmpty(this.expendType)){
            query.eq(SysClass::getExpendType, this.expendType);
        }

        if(this.deep>0){
            query.eq(SysClass::getDeep, this.deep);
        }

        if(!StringUtils.isEmpty(this.typeInfo)){
            query.eq(SysClass::getTypeInfo, this.typeInfo);
        }

        if(!StringUtils.isEmpty(this.img)){
            query.eq(SysClass::getImg, this.img);
        }

        if(this.orderNum>0){
            query.eq(SysClass::getOrderNum, this.orderNum);
        }

        if(!StringUtils.isEmpty(this.remarks)){
            query.eq(SysClass::getRemarks, this.remarks);
        }

        if(this.infoLevel>0){
            query.eq(SysClass::getInfoLevel, this.infoLevel);
        }

        if(this.tenantType>0){
            query.eq(SysClass::getTenantType, this.tenantType);
        }

        if(this.tenantId>0){
            query.eq(SysClass::getTenantId, this.tenantId);
        }

        if(this.delState>0){
            query.eq(SysClass::getDelState, this.delState);
        }

        if(!StringUtils.isEmpty(this.addUser)){
            query.eq(SysClass::getAddUser, this.addUser);
        }

        if(this.addUserId>0){
            query.eq(SysClass::getAddUserId, this.addUserId);
        }

        if(null!=this.addTime){
            query.eq(SysClass::getAddTime, this.addTime);
        }

        if(!StringUtils.isEmpty(this.editUser)){
            query.eq(SysClass::getEditUser, this.editUser);
        }

        if(this.editUserId>0){
            query.eq(SysClass::getEditUserId, this.editUserId);
        }

        if(null!=this.lastEditTime){
            query.eq(SysClass::getLastEditTime, this.lastEditTime);
        }

        if(this.serverNumber>0){
            query.eq(SysClass::getServerNumber, this.serverNumber);
        }



        return  query;

    }

    @JsonIgnore
    public static LambdaQueryWrapper<SysClass> getQuery(){
        var query = new QueryWrapper<SysClass>().lambda();
        return query;
    }


    @JsonIgnore
    public LambdaUpdateWrapper<SysClass> getUpdateWrapper() {
        var  updateWrapper = new UpdateWrapper<SysClass>().lambda();

        if(this.id>0){

            updateWrapper.eq(SysClass::getId, this.id);

        }

        if(!StringUtils.isEmpty(this.name)){

            updateWrapper.set(SysClass::getName, this.name);

        }

        if(this.parentId>0){

            updateWrapper.set(SysClass::getParentId, this.parentId);

        }

        if(!StringUtils.isEmpty(this.parentIdPath)){

            updateWrapper.set(SysClass::getParentIdPath, this.parentIdPath);

        }

        if(!StringUtils.isEmpty(this.expendType)){

            updateWrapper.set(SysClass::getExpendType, this.expendType);

        }

        if(this.deep>0){

            updateWrapper.set(SysClass::getDeep, this.deep);

        }

        if(!StringUtils.isEmpty(this.typeInfo)){

            updateWrapper.set(SysClass::getTypeInfo, this.typeInfo);

        }

        if(!StringUtils.isEmpty(this.img)){

            updateWrapper.set(SysClass::getImg, this.img);

        }

        if(this.orderNum>0){

            updateWrapper.set(SysClass::getOrderNum, this.orderNum);

        }

        if(!StringUtils.isEmpty(this.remarks)){

            updateWrapper.set(SysClass::getRemarks, this.remarks);

        }

        if(this.infoLevel>0){

            updateWrapper.set(SysClass::getInfoLevel, this.infoLevel);

        }

        if(this.tenantType>0){

            updateWrapper.set(SysClass::getTenantType, this.tenantType);

        }

        if(this.tenantId>0){

            updateWrapper.set(SysClass::getTenantId, this.tenantId);

        }

        if(this.delState>0){

            updateWrapper.set(SysClass::getDelState, this.delState);

        }

        if(!StringUtils.isEmpty(this.addUser)){

            updateWrapper.set(SysClass::getAddUser, this.addUser);

        }

        if(this.addUserId>0){

            updateWrapper.set(SysClass::getAddUserId, this.addUserId);

        }

        if(null!=this.addTime){

            updateWrapper.set(SysClass::getAddTime, this.addTime);

        }

        if(!StringUtils.isEmpty(this.editUser)){

            updateWrapper.set(SysClass::getEditUser, this.editUser);

        }

        if(this.editUserId>0){

            updateWrapper.set(SysClass::getEditUserId, this.editUserId);

        }

        if(null!=this.lastEditTime){

            updateWrapper.set(SysClass::getLastEditTime, this.lastEditTime);

        }

        if(this.serverNumber>0){

            updateWrapper.set(SysClass::getServerNumber, this.serverNumber);

        }



        return updateWrapper;
    }

}

